---
- name: allow Apache to remotely connect to mysql
  seboolean: name=httpd_can_network_connect_db state=yes persistent=yes
  tags:
  - mediawiki

- name: allow Apache to remotely connect to wiki
  seboolean: name=httpd_can_network_connect state=yes persistent=yes
  tags:
  - mediawiki

- name: allow Apache to remotely connect to Memcached
  seboolean: name=httpd_can_network_memcache state=yes persistent=yes
  tags:
  - mediawiki

- name: allow Apache to talk to the wiki uploads dir over nfs
  seboolean: name=httpd_use_nfs state=yes persistent=yes
  tags:
  - mediawiki

- name: set sebooleans so apache can send emails
  seboolean: name=httpd_can_sendmail state=yes persistent=yes
  tags:
  - mediawiki

- name: install needed packages
  package: name={{ item }} state=present
  with_items:
  - "{{ wikiver }}"
  - "{{ wikiver }}-Lockdown"
  - "{{ wikiver }}-SpecialInterwiki"
  - "{{ wikiver }}-HTTP302Found"
  - "{{ wikiver }}-RSS"
  - mediawiki-FedoraBadges
  - "{{ wikiver }}-basset"
  - php-zmq
  - php-pecl-uuid
  - librsvg2
  tags:
  - packages
  - mediawiki

- name: install needed packages (el7 only)
  package: name={{ item }} state=present
  with_items:
  - "{{ wikiver }}-Cite"
  - "{{ wikiver }}-intersection"
  tags:
  - packages
  - mediawiki
  when: env != 'staging'

- name: install needed packages (fedora only)
  package: name={{ item }} state=present
  with_items:
  - "{{ wikiver }}-openid"
  - "{{ wikiver }}-skin-fedora"
  - php-mysqlnd
  tags:
  - packages
  - mediawiki
  when: env == 'staging'

- name: adding FAS auth
  #template: src=Auth_FAS_CLAPLUSONE.php.j2
  template: src=Auth_FAS.php.j2
            dest=/usr/share/{{ wikiver }}/extensions/Auth_FAS.php owner=root group=root mode=775
  tags:
  - config
  - mediawiki
  when: env != 'staging'

- name: adding fedmsg emit
  copy: src=fedmsg-emit.php dest=/usr/share/{{ wikiver }}/extensions/fedmsg-emit.php owner=root group=root mode=775
  tags:
  - config
  - mediawiki

- name: startup apache
  service: name=httpd enabled=yes state=started
  tags:
  - mediawiki

- name: Fedora branding
  copy: src=skins/ dest=/usr/share/{{ wikiver }}/skins owner=root group=root mode=775
  tags:
  - config
  - mediawiki
  when: env != 'staging'

- name: creating wiki dir
  file: path=/srv/web/{{wikiname}}-wiki owner=root group=root mode=755 state=directory
  tags:
  - mediawiki

#- name: creating config dir
#  file: src=/usr/share/{{ wikiver }}/config dest=/srv/web/{{wikiname}}/config owner=apache group=apache mode=755 state=directory
#  tags:
#  - mediawiki

# This doesn't seem to exist anymore in upstream....
#- name: install utils
#  file: src=/usr/share/{{ wikiver }}/install-utils.inc dest=/srv/web/{{wikiname}}-wiki/install-utils.inc state=link
#  tags:
#  - mediawiki

- name: install localsettings
  template: src=LocalSettings.php.{{wikiname}}.j2 dest=/srv/web/{{wikiname}}-wiki/LocalSettings.php owner=apache group=apache mode=600 setype=httpd_sys_content_t
  notify: reload httpd
  tags:
  - mediawiki

- name: httpd conf
  template: src=mediawiki-app.conf.j2 dest=/etc/httpd/conf.d/{{wikiname}}.conf
  notify: reload httpd
  tags:
  - mediawiki

- name: linking index.php
  file: dest=/srv/web/{{wikiname}}-wiki/index.php src=/usr/share/{{ wikiver }}/index.php state=link
  tags:
  - mediawiki

- name: linkng api.php
  file: dest=/srv/web/{{wikiname}}-wiki/api.php src=/usr/share/{{ wikiver }}/api.php state=link
  tags:
  - mediawiki

- name: linking opensearch
  file: dest=/srv/web/{{wikiname}}-wiki/opensearch_desc.php src=/usr/share/{{ wikiver }}/opensearch_desc.php state=link
  tags:
  - mediawiki

- name: linking extensions
  file: dest=/srv/web/{{wikiname}}-wiki/extensions src=/usr/share/{{ wikiver }}/extensions state=link
  tags:
  - mediawiki

- name: linking includes
  file: dest=/srv/web/{{wikiname}}-wiki/includes src=/usr/share/{{ wikiver }}/includes state=link
  tags:
  - mediawiki

- name: linking languages
  file: dest=/srv/web/{{wikiname}}-wiki/languages src=/usr/share/{{ wikiver }}/languages state=link
  tags:
  - mediawiki

- name: linking maintenance
  file: dest=/srv/web/{{wikiname}}-wiki/maintenance src=/usr/share/{{ wikiver }}/maintenance state=link
  tags:
  - mediawiki

- name: linking serialized
  file: dest=/srv/web/{{wikiname}}-wiki/serialized src=/usr/share/{{ wikiver }}/serialized state=link
  tags:
  - mediawiki

- name: linking skins
  file: dest=/srv/web/{{wikiname}}-wiki/skins src=/usr/share/{{ wikiver }}/skins state=link
  tags:
  - mediawiki

- name: linking load
  file: dest=/srv/web/{{wikiname}}-wiki/load.php src=/usr/share/{{ wikiver }}/load.php state=link
  tags:
  - mediawiki

- name: linking resources
  file: dest=/srv/web/{{wikiname}}-wiki/resources src=/usr/share/{{ wikiver }}/resources state=link
  tags:
  - mediawiki
